package IO;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Demo12 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("./test.txt")){
            while(true){
                byte[] buffer = new byte[1024];

                //这个操作会将在硬盘中读到的对应数据，填充到 buffer 内存的字节数组中，尽可能填满
                //一次 IO 就尽可能填满
                int n = inputStream.read(buffer);
                if(n == -1){
                    break ;
                }
                for (int i = 0; i < n; i++) {
                    System.out.printf("0x%x\n",buffer[i]);
                }
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
